/**
 * Copyright (c) 2008, Andrew Carter
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, are 
 * permitted provided that the following conditions are met:
 * 
 * Redistributions of source code must retain the above copyright notice, this list of 
 * conditions and the following disclaimer. Redistributions in binary form must reproduce 
 * the above copyright notice, this list of conditions and the following disclaimer in 
 * the documentation and/or other materials provided with the distribution. Neither the 
 * name of Andrew Carter nor the names of contributors may be used to endorse or promote 
 * products derived from this software without specific prior written permission. 
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
 * SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 
 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
package com.acarter.jmejtree.util;


/**
 * Enumerates the permissible render state types for jME 2.0.
 * 
 * @author Andrew Carter
 */
public enum E_RenderState {

	/** The value returned by getType() for BlendState. */
	RS_BLEND("Blend State", 0),

	/** The value returned by getType() for FogState. */
	RS_FOG("Fog State", 1),

	/** The value returned by getType() for LightState. */
	RS_LIGHT("Light State", 2),

	/** The value returend by getType() for MaterialState. */
	RS_MATERIAL("Material State", 3),

	/** The value returned by getType() for ShadeState. */
	RS_SHADE("Shade State", 4),

	/** The value returned by getType() for TextureState. */
	RS_TEXTURE("Texture State", 5),

	/** The value returned by getType() for WireframeState. */
	RS_WIREFRAME("Wireframe State", 6),

	/** The value returned by getType() for ZBufferState. */
	RS_ZBUFFER("Z-Buffer State", 7),

	/** The value returned by getType() for CullState. */
	RS_CULL("Cull State", 8),

	/** The value returned by getType() for VertexProgramState. */
	RS_VERTEX_PROGRAM("Vertex Program State", 9),

	/** The value returned by getType() for FragmentProgramState. */
	RS_FRAGMENT_PROGRAM("Fragment Program State", 10),

	/** The value returned by getType() for StencilState. */
	RS_STENCIL("Stencil State", 11),
	
	/** The value returned by getType() for ShaderObjectsState. */
	RS_GLSL_SHADER_OBJECTS("GLSL Shader Objects State", 12),

    /** The value returned by getType() for ColorMaskState. */    
	RS_COLORMASK_STATE("Color Mask State", 13), 

    /** The value returned by getType() for ClipState. */
	RS_CLIP("Clip State", 14);

	/** String representation of the enum value */
	private String name;

	/** Integer value of the enum value */
	private int value;

	/**
	 * Private constructor.
	 * 
	 * @param value
	 *            String literal of the enum
	 */
	private E_RenderState(String name, int value) {

		this.name = name;
		this.value = value;
	}

	/**
	 * Returns the enum constant matching the name string.
	 * 
	 * @param name
	 *            string value of enum constant
	 * @return matching enum constant or null
	 */
	public static E_RenderState getConstant(String name) {

		for (E_RenderState constant : E_RenderState.values()) {

			if (constant.toString().compareToIgnoreCase(name) == 0)
				return constant;
		}

		return null;
	}

	/**
	 * Returns the enum constant matching the type value.
	 * 
	 * @param type
	 *            type value of enum constant
	 * @return matching enum constant or null
	 */
	public static E_RenderState getConstant(int type) {

		for (E_RenderState constant : E_RenderState.values()) {

			if (constant.getType() == type)
				return constant;
		}

		return null;
	}

	/**
	 * Returns the string value of the constant.
	 */
	public String toString() {

		return name;
	}
	
	/**
	 * Returns the integer value of the constant.
	 * @return 
	 */
	public int getType() {
		
		return value;
	}
}
